package d11_test02;

import java.util.ArrayList;
import java.util.List;

//关键点在于,奖池只有一个
public class Test02_2 {
    //1、初始化奖池
    private static final int[] PRAISES =
            {10,5,20,50,100,200,500,800,2,80,300,700};
    //2、创建奖池
    private static List<Integer> jackpot = new ArrayList<>();

    //3、使用静态代码块进行初始化
    static{
        for (int praise : PRAISES) {
            //压到集合里面去
            jackpot.add(praise);
        }
    }

    public static void main(String[] args) {

        //1、创建任务
        MyRunnable02_2 target = new MyRunnable02_2(jackpot);

        //2、创建两个抽奖箱线程
        Thread firstBox = new Thread(target, "抽奖箱1");
        Thread secondBox = new Thread(target, "抽奖箱2");

        //3、启动线程
        firstBox.start();
        secondBox.start();


        // 5. 等待线程结束
        try {
            firstBox.join();
            secondBox.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //4、展示结果

        target.printResults();
    }
}
